<template>
	<view>
		<view class="xi">
			<my-search @my-click="gotosearch"></my-search>
		</view>
		
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular>
			<swiper-item  v-for="(item,index) in shopimg" :key="index">
				<navigator :url="'/subpkg/shop_details/shop_details?goods_id=' + item.goods_id" class="swiper-item">
					<image :src="item.image_src" mode=""></image>
				</navigator>
			</swiper-item>
		</swiper>
		
		
		<view class="nav_list">
			<view class="nav_item"  v-for="(item,index) in navdata" :key=index @click="gotoclassify(item)">
				<image class="nav_img" :src="item.image_src" mode=""></image>
				
			</view>
		</view>
		
		<view class="follor">
			<view class="folor_item" v-for="(item,index) in follorlist" :key="index">
				<image :src="item.floor_title.image_src" class="folor_title"></image>
				<view class="img_box">
					<navigator class="follor_left" :url="item.product_list[0].url">
						<image :src="item.product_list[0].image_src" mode="widthFix" :style="{width: item.product_list[0].image_width + 'rpx'}"></image>
					</navigator>
					
					<view class="foller_right">
						<navigator  class="flooer_right_item" v-for="(item2,index2) in item.product_list" :key="index2" v-if="index2 !== 0" :url="item2.url">
							<image :src="item2.image_src" mode="widthFix" :style="{width: item2.image_width + 'rpx'}"></image>
						</navigator>
					</view>
					
				</view>
				
			</view>
			
			
			
		</view>
		
		
	</view>
</template>

<script>
	import bdage from '@/mixins/tabbar-baage.js'
	export default {
		mixins: [bdage],
		data() {
			return {
				// 轮播图数据
				shopimg: [],
				// 导航栏数据
				navdata: [],
				follorlist: []
			};
		},
		onLoad() {
			this.getswipeing()
			this.getnavdata()
			this.getfollorlist()
		},
		methods: {
			async getswipeing () {
				const {data: res} =await uni.$http.get('/api/public/v1/home/swiperdata')
				if (res.meta.status !== 200) return uni.$showmsg()
				this.shopimg = res.message
				uni.$showmsg('数据加载成功')
			},
			async getnavdata () {
				const {data: res} = await uni.$http.get('/api/public/v1/home/catitems')
				if (res.meta.status !== 200) return uni.$showmsg()
				this.navdata = res.message
				
			},
			gotoclassify (item) {
				if (item.name === '分类') {
					return uni.switchTab({
						url: '/pages/cate/cate'
					})
				}
			},
			async getfollorlist () {
				const {data: res} = await uni.$http.get('/api/public/v1/home/floordata')
				console.log(res)
				if (res.meta.status !== 200) return uni.$showmsg()
				res.message.forEach(item => {
					item.product_list.forEach(item2 => {
						item2.url = '/subpkg/shop_list/shop_list?' + item2.navigator_url.split('?')[1]
					})
				})
				this.follorlist = res.message
			},
			gotosearch () {
				uni.navigateTo({
					url: '../../subpkg/search/search'
				})
			}
		}
	}
</script>

<style lang="scss">
.swiper-item {
	height: 330rpx;
	image {
		height: 100%;
		width: 100%;
	}
}
.nav_list {
	display: flex;
	justify-content: space-around;
	margin: 15rpx 0;
	.nav_img {
		width: 128rpx;
		height: 140rpx;
	}
}
.folor_title {
	width: 100%;
	height: 60rpx;
}
.foller_right {
	padding-left: 30rpx;
	display: flex;
	flex-wrap: wrap;
}
.img_box {
	display: flex;
}
.follor_left {
	padding-left: 10rpx;
}
.xi {
	position: sticky;
	top: 0;
	z-index: 999;
}
</style>
